# CMakeList.txt: gitstore 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.8)
#set(CMAKE_CXX_STANDARD 17)
#project(GitStoreGrpcService)
#message(${CMAKE_C_FLAGS_DEBUG})
#set(CMAKE_BUILD_TYPE "Debug")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -g2 -ggdb -ldl -pthread")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -g2 -ggdb -ldl -pthread")
#add_definitions(-D _FILE_OFFSET_BITS=64)
message(${CMAKE_CXX_FLAGS_DEBUG})
#include_directories("/usr/include" "/usr/local/include/etcd" "/usr/local/include/etcd/proto"  "../GitStoreGrpcLib")
#link_directories("/usr/lib" "/usr/local/lib" "/usr/lib/x86_64-linux-gnu")

# 将源代码添加到此项目的可执行文件。
find_package(gRPC CONFIG REQUIRED)
find_library(ETCD_CPP_API_LIB etcd-cpp-api CMAKE_LIBRARY_PATH)
find_library(CPPREST_LIB cpprest CMAKE_LIBRARY_PATH)
add_executable(GitStoreGrpcService "main.cpp" "servicedefine.h" "servicedefine.cpp" "Utils.h")
target_link_libraries(GitStoreGrpcService GitStoreMeta GitStoreGrpcLib)

if(gRPC_FOUND)
    message("grpc found!")
#    message(STATUS ${gRPC_INCLUDE_DIR})
    target_include_directories(GitStoreGrpcService PUBLIC $<TARGET_PROPERTY:gRPC::grpc++,INTERFACE_INCLUDE_DIRECTORIES>)
    target_link_libraries(GitStoreGrpcService gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_reflection)
else()
    message(FATAL_ERROR "grpc lib not found!")
#    target_link_libraries(GitStoreGrpcService gpr grpc grpc++ grpc++_reflection)
#    target_link_libraries(GitStoreGrpcService crypto grpc++ grpc grpc++_reflection cares ssl /usr/local/lib/libprotobuf.so address_sorting /usr/local/lib/libgpr.so)
endif()

if(NOT ETCD_CPP_API_LIB)
    message(FATAL_ERROR "etcd-cpp-api lib not found!")
else()
    target_include_directories(GitStoreGrpcService PUBLIC "/usr/local/include/etcd" "/usr/local/include/etcd/proto")
endif()

if(NOT CPPREST_LIB)
    message(FATAL_ERROR "cpprest lib not found!")
else()
    target_link_libraries(GitStoreGrpcService cpprest)
endif()

target_include_directories(GitStoreGrpcService PUBLIC "../GitStoreGrpcLib")

# TODO: 如有需要，请添加测试并安装目标。
